home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / mail / mailx6 / _setup.1 / SESSIONF.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-04-11  |  4.3 KB  |  188 lines

  1. unit Sessionf;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls, MXMAILX;
  8.  
  9. {$I mailxdef.int}
  10. type
  11.   TSimpleForm = class(TForm)
  12.     Label1: TLabel;
  13.     Label2: TLabel;
  14.     Label3: TLabel;
  15.     szNames: TEdit;
  16.     szCount: TLabel;
  17.     btlResolve: TButton;
  18.     Button2: TButton;
  19.     Button3: TButton;
  20.     Button4: TButton;
  21.     Button5: TButton;
  22.     Button6: TButton;
  23.     btnLogin: TButton;
  24.     MXForm1: TMXForm;
  25.     MXSession1: TMXSession;
  26.     MXMessage1: TMXMessage;
  27.     MXRecipient1: TMXRecipient;
  28.     procedure FormCreate(Sender: TObject);
  29.     procedure btnLoginClick(Sender: TObject);
  30.     procedure btlResolveClick(Sender: TObject);
  31.     procedure Button3Click(Sender: TObject);
  32.     procedure Button5Click(Sender: TObject);
  33.     function  IsSessionActive:Boolean;
  34.     procedure Button2Click(Sender: TObject);
  35.     procedure Button4Click(Sender: TObject);
  36.     procedure Button6Click(Sender: TObject);
  37.     procedure UpdateText;
  38.     procedure UpdateCount;
  39.  
  40.   private
  41.     { Private declarations }
  42.   public
  43.     { Public declarations }
  44.   end;
  45.  
  46. var
  47.   SimpleForm: TSimpleForm;
  48.  
  49. implementation
  50.  
  51. {$R *.DFM}
  52. uses mailsys2;
  53.  
  54.  
  55. procedure TSimpleForm.FormCreate(Sender: TObject);
  56. var
  57.    MailSystem: TMailSystem;
  58. begin
  59.      MailSystem:=TMailSystem.Create(Self);
  60.      MailSystem.ShowModal;
  61.      MailSystem.free;
  62.  
  63. end;
  64.  
  65. procedure TSimpleForm.btnLoginClick(Sender: TObject);
  66. begin
  67.      MXSession1.Logon:=TRUE;
  68.      if IsSessionActive then
  69.      begin
  70.           UpdateCount;
  71.      end
  72.      else
  73.      begin
  74.          szNames.Text:='';
  75.          szCount.Caption:='';
  76.      end;
  77.  
  78. end;
  79.  
  80. procedure TSimpleForm.btlResolveClick(Sender: TObject);
  81. begin
  82.      if IsSessionActive then
  83.      begin
  84.           MXRecipient1.ResolveName:=szNames.Text;
  85.           szNames.Text:=MXRecipient1.ResolveName;
  86.      end;
  87. end;
  88.  
  89. procedure TSimpleForm.UpdateText;
  90. begin
  91.      if MXRecipient1.RecipientCount=0 then szNames.Text:=''
  92.      else szNames.Text:=MXRecipient1.RecipientName;
  93. end;
  94.  
  95. procedure TSimpleForm.UpdateCount;
  96. begin
  97.      szCount.Caption:=IntToStr(MXRecipient1.RecipientCount);
  98. end;
  99.  
  100. procedure TSimpleForm.Button3Click(Sender: TObject);
  101. begin
  102.      if IsSessionActive then
  103.      begin
  104.           MXRecipient1.Action:=ACTION_ADDRECIPIENT;
  105.           UpdateCount;
  106.           UpdateText;
  107.      end;
  108. end;
  109.  
  110. procedure TSimpleForm.Button5Click(Sender: TObject);
  111. begin
  112.      if IsSessionActive then
  113.      begin
  114.           MXRecipient1.Action:=ACTION_ADDRESS;
  115.           UpdateCount;
  116.           UpdateText;
  117.      end;
  118. end;
  119.  
  120. function  TSimpleForm.IsSessionActive:Boolean;
  121. begin
  122.      if MXSession1.Logon=TRUE then
  123.      begin
  124.           Result:=TRUE;
  125.      end
  126.      else
  127.      begin
  128.          Application.MessageBox('No Active Session available',
  129.                                 'Mail eXtension DEMO for DELPHI',
  130.                                 MB_ICONSTOP);
  131.          Result:=FALSE;
  132.      end;
  133. end;
  134.  
  135. procedure TSimpleForm.Button2Click(Sender: TObject);
  136. var
  137.    NextR: Integer;
  138. begin
  139.      if IsSessionActive then
  140.      begin
  141.           If MXRecipient1.RecipientCount > 0 Then
  142.           begin
  143.              MXRecipient1.RecipientNum:= 1;
  144.              UpdateText;
  145.           end
  146.           Else
  147.           begin
  148.               Application.MessageBox('Mail X Recipient Control is Empty',
  149.                                      'Mail X DEMO for DELPHI',
  150.                                      MB_ICONINFORMATION);
  151.           end;
  152.      end;
  153. end;
  154.  
  155. procedure TSimpleForm.Button4Click(Sender: TObject);
  156. var
  157.    NextR: Integer;
  158. begin
  159.      if IsSessionActive then
  160.      begin
  161.           NextR:= MXRecipient1.RecipientNum + 1;
  162.           If NextR <= MXRecipient1.RecipientCount Then
  163.           begin
  164.              MXRecipient1.RecipientNum := NextR;
  165.              UpdateText;
  166.           end
  167.           Else
  168.           begin
  169.               Application.MessageBox('Last Recipient Reached',
  170.                                      'Mail X DEMO for DELPHI',
  171.                                      MB_ICONINFORMATION);
  172.           end;
  173.      end;
  174. end;
  175.  
  176. procedure TSimpleForm.Button6Click(Sender: TObject);
  177. begin
  178.      if IsSessionActive then
  179.      begin
  180.           MXRecipient1.Action:= ACTION_DEL_RECIPIENT;
  181.           UpdateCount;
  182.           UpdateText;
  183.      end;
  184. end;
  185.  
  186. end.
  187.  
  188.